﻿using System;
using System.Text;
using IAM.Interface.Model.Interface;
using System.Xml;

namespace IAM.Interface.Model
{
    /// <summary>
    /// 用户权限
    /// </summary>
    public class ACI : AbstractConvertObject, IConvertXml
    {
        #region 属性
        private AccountInfo _accountinfo = null;
        private ACISessions _acisessions = null;
        /// <summary>
        /// 用户的账号信息
        /// </summary>
        public AccountInfo AccountInfo
        {
            set
            {
                _accountinfo = value;
            }
            get
            {
                return _accountinfo;
            }

        }
        /// <summary>
        /// 用户的账号的权限
        /// </summary>
        public ACISessions ACISessions
        {
            get
            {
                return _acisessions;
            }
            set
            {
                _acisessions = value;
            }
        }
        #endregion
        #region IConvertXml

        public string XMLBoday
        {
            get
            {
                StringBuilder _xml = new StringBuilder();
                _xml.Append(AccountInfo.XML);
                _xml.Append(ACISessions.XML);
                return _xml.ToString();
            }


        }
        public string XMLFinis
        {
            get
            {
                return "";
            }
        }
        public string XML
        {
            get
            {
                return XMLBoday + XMLFinis;
            }
        }
        #endregion
        #region AbstractConvertObject
        public override object ConvertToObject()
        {  
            //1.AccountInfo
            XmlNode xn = this.CurrentXmlNode.SelectSingleNode("AccountInfo");
            this.AccountInfo = new AccountInfo();
            this.AccountInfo.CurrentXmlNode = xn;
            this.AccountInfo = (AccountInfo)this.AccountInfo.ConvertToObject();
            //2.ACISessions
            xn = this.CurrentXmlNode.SelectSingleNode("ACISessions");
            this.ACISessions = new ACISessions();
            this.ACISessions.CurrentXmlNode = xn;
            this.ACISessions = (ACISessions)this.ACISessions.ConvertToObject();
            return this;
        }
        #endregion
    }
}
